aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/oss_output_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-03-21 23:47:29 +0100
committerMax Kellermann <max@duempel.org>2012-03-22 00:33:40 +0100
commit921cc3e5db7a07ba683dae7834c6cb2e03a6a8f3 (patch)
treeec1f2f65c9074a6ff5f961e0fd853cd544586ea8 /src/output/oss_output_plugin.c
parent51dce3d1616603b44e0da8a7374d0cbf3efb7a2f (diff)
downloadmpd-921cc3e5db7a07ba683dae7834c6cb2e03a6a8f3.tar.gz
mpd-921cc3e5db7a07ba683dae7834c6cb2e03a6a8f3.tar.xz
mpd-921cc3e5db7a07ba683dae7834c6cb2e03a6a8f3.zip
output/oss: remember the real OSS format
Improving oss_reopen() by using the very same value that was used initially.
Diffstat (limited to 'src/output/oss_output_plugin.c')
-rw-r--r--src/output/oss_output_plugin.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/output/oss_output_plugin.c b/src/output/oss_output_plugin.c
index 4f22ddb7d..c32fceade 100644
--- a/src/output/oss_output_plugin.c
+++ b/src/output/oss_output_plugin.c
@@ -71,6 +71,12 @@ struct oss_data {
* the device after cancel().
*/
struct audio_format audio_format;
+
+ /**
+ * The current OSS audio format. This is needed to reopen the
+ * device after cancel().
+ */
+ int oss_format;
};
/**
@@ -504,6 +510,7 @@ sample_format_from_oss(int format)
static enum oss_setup_result
oss_probe_sample_format(int fd, enum sample_format sample_format,
enum sample_format *sample_format_r,
+ int *oss_format_r,
#ifdef AFMT_S24_PACKED
struct pcm_export_state *export,
#endif
@@ -525,6 +532,7 @@ oss_probe_sample_format(int fd, enum sample_format sample_format,
return UNSUPPORTED;
*sample_format_r = sample_format;
+ *oss_format_r = oss_format;
#ifdef AFMT_S24_PACKED
pcm_export_open(export, sample_format,
@@ -541,6 +549,7 @@ oss_probe_sample_format(int fd, enum sample_format sample_format,
*/
static bool
oss_setup_sample_format(int fd, struct audio_format *audio_format,
+ int *oss_format_r,
#ifdef AFMT_S24_PACKED
struct pcm_export_state *export,
#endif
@@ -549,7 +558,7 @@ oss_setup_sample_format(int fd, struct audio_format *audio_format,
enum sample_format mpd_format;
enum oss_setup_result result =
oss_probe_sample_format(fd, audio_format->format,
- &mpd_format,
+ &mpd_format, oss_format_r,
#ifdef AFMT_S24_PACKED
export,
#endif
@@ -588,7 +597,7 @@ oss_setup_sample_format(int fd, struct audio_format *audio_format,
continue;
result = oss_probe_sample_format(fd, mpd_format,
- &mpd_format,
+ &mpd_format, oss_format_r,
#ifdef AFMT_S24_PACKED
export,
#endif
@@ -620,7 +629,7 @@ oss_setup(struct oss_data *od, struct audio_format *audio_format,
{
return oss_setup_channels(od->fd, audio_format, error_r) &&
oss_setup_sample_rate(od->fd, audio_format, error_r) &&
- oss_setup_sample_format(od->fd, audio_format,
+ oss_setup_sample_format(od->fd, audio_format, &od->oss_format,
#ifdef AFMT_S24_PACKED
&od->export,
#endif
@@ -668,9 +677,8 @@ oss_reopen(struct oss_data *od, GError **error_r)
}
const char *const msg3 = "Failed to set sample format";
- assert(sample_format_to_oss(od->audio_format.format) != AFMT_QUERY);
result = oss_try_ioctl(od->fd, SNDCTL_DSP_SAMPLESIZE,
- sample_format_to_oss(od->audio_format.format),
+ od->oss_format,
msg3, error_r);
if (result != SUCCESS) {
oss_close(od);