-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update alsa.h #17092
Open
Laggamer2005
wants to merge
1
commit into
libretro:master
Choose a base branch
from
Laggamer2005:patch-5
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update alsa.h #17092
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -14,43 +14,98 @@ | |||||||||
*/ | ||||||||||
|
||||||||||
|
||||||||||
#ifndef _RETROARCH_ALSA | ||||||||||
#define _RETROARCH_ALSA | ||||||||||
#ifndef RETROARCH_ALSA_H | ||||||||||
#define RETROARCH_ALSA_H | ||||||||||
|
||||||||||
#include <boolean.h> | ||||||||||
#include <queues/fifo_queue.h> | ||||||||||
#include <rthreads/rthreads.h> | ||||||||||
|
||||||||||
/* Header file for common functions that are used by alsa and alsathread. */ | ||||||||||
#include <stdbool.h> | ||||||||||
#include <stddef.h> | ||||||||||
#include <alsa/asoundlib.h> | ||||||||||
|
||||||||||
/** | ||||||||||
* Used for info that's common to all pcm devices | ||||||||||
* that's relevant for our purposes. | ||||||||||
* @brief Common information for PCM devices. | ||||||||||
*/ | ||||||||||
typedef struct alsa_stream_info | ||||||||||
{ | ||||||||||
size_t buffer_size; | ||||||||||
size_t period_size; | ||||||||||
snd_pcm_uframes_t period_frames; | ||||||||||
unsigned int frame_bits; | ||||||||||
bool has_float; | ||||||||||
bool can_pause; | ||||||||||
typedef struct alsa_stream_info { | ||||||||||
size_t buffer_size; | ||||||||||
size_t period_size; | ||||||||||
snd_pcm_uframes_t period_frames; | ||||||||||
unsigned int frame_bits; | ||||||||||
bool has_float; | ||||||||||
bool can_pause; | ||||||||||
} alsa_stream_info_t; | ||||||||||
|
||||||||||
/** | ||||||||||
* @brief Initialize a PCM device. | ||||||||||
* | ||||||||||
* @param[out] pcm Pointer to the PCM handle. | ||||||||||
* @param[in] device Device name. | ||||||||||
* @param[in] stream Stream direction (playback or capture). | ||||||||||
* @param[in] rate Desired sample rate. | ||||||||||
* @param[in] latency Desired latency in milliseconds. | ||||||||||
* @param[in] channels Number of channels. | ||||||||||
* @param[out] stream_info Pointer to store stream information. | ||||||||||
* @param[out] new_rate Pointer to store the actual sample rate. | ||||||||||
* @param[in] mode ALSA open mode. | ||||||||||
* @return int 0 on success, negative error code on failure. | ||||||||||
*/ | ||||||||||
int alsa_init_pcm(snd_pcm_t **pcm, | ||||||||||
const char* device, | ||||||||||
snd_pcm_stream_t stream, | ||||||||||
unsigned rate, | ||||||||||
unsigned latency, | ||||||||||
unsigned channels, | ||||||||||
alsa_stream_info_t *stream_info, | ||||||||||
unsigned *new_rate, | ||||||||||
int mode); | ||||||||||
const char *device, | ||||||||||
snd_pcm_stream_t stream, | ||||||||||
unsigned int rate, | ||||||||||
unsigned int latency, | ||||||||||
unsigned int channels, | ||||||||||
alsa_stream_info_t *stream_info, | ||||||||||
unsigned int *new_rate, | ||||||||||
int mode); | ||||||||||
|
||||||||||
/** | ||||||||||
* @brief Free a PCM device. | ||||||||||
* | ||||||||||
* @param pcm PCM handle to free. | ||||||||||
*/ | ||||||||||
void alsa_free_pcm(snd_pcm_t *pcm); | ||||||||||
|
||||||||||
/** | ||||||||||
* @brief Create a new ALSA device list. | ||||||||||
* | ||||||||||
* @param data User data. | ||||||||||
* @return void* Pointer to the new device list. | ||||||||||
*/ | ||||||||||
void *alsa_device_list_new(void *data); | ||||||||||
struct string_list *alsa_device_list_type_new(const char* type); | ||||||||||
|
||||||||||
/** | ||||||||||
* @brief Create a new ALSA device list of a specific type. | ||||||||||
* | ||||||||||
* @param type Device type. | ||||||||||
* @return struct string_list* List of devices. | ||||||||||
*/ | ||||||||||
struct string_list *alsa_device_list_type_new(const char *type); | ||||||||||
|
||||||||||
/** | ||||||||||
* @brief Free an ALSA device list. | ||||||||||
* | ||||||||||
* @param data User data. | ||||||||||
* @param array_list_data Array list data to free. | ||||||||||
*/ | ||||||||||
void alsa_device_list_free(void *data, void *array_list_data); | ||||||||||
|
||||||||||
/** | ||||||||||
* @brief Start a PCM device. | ||||||||||
* | ||||||||||
* @param pcm PCM handle. | ||||||||||
* @return true if successful, false otherwise. | ||||||||||
*/ | ||||||||||
bool alsa_start_pcm(snd_pcm_t *pcm); | ||||||||||
|
||||||||||
/** | ||||||||||
* @brief Stop a PCM device. | ||||||||||
* | ||||||||||
* @param pcm PCM handle. | ||||||||||
* @return true if successful, false otherwise. | ||||||||||
*/ | ||||||||||
bool alsa_stop_pcm(snd_pcm_t *pcm); | ||||||||||
|
||||||||||
#endif /* RETROARCH_ALSA_H */ | ||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now the below code is redundant |
||||||||||
bool alsa_start_pcm(snd_pcm_t *pcm); | ||||||||||
bool alsa_stop_pcm(snd_pcm_t *pcm); | ||||||||||
|
||||||||||
Comment on lines
+107
to
111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As viachaslavic mentioned, likely don't need these last few lines, as the #endif is below
Suggested change
|
||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the code style