From: Nutchanon Wetchasit <Nutchanon.Wetchasit@gmail.com>
Subject: Fix build failure when "--disable-media" configure option was used.
Bug: https://savannah.gnu.org/bugs/?27952

This fixes the build failure part of bug #27952.
See <https://savannah.gnu.org/bugs/?27952>

diff --git a/libcore/asobj/NetStream_as.cpp b/libcore/asobj/NetStream_as.cpp
index 99d2a7a..06dec58 100644
--- a/libcore/asobj/NetStream_as.cpp
+++ b/libcore/asobj/NetStream_as.cpp
@@ -1,7 +1,7 @@
 // NetStream.cpp:  ActionScript class for streaming audio/video, for Gnash.
 // 
-//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-//   Free Software Foundation, Inc
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
+//   2016 Free Software Foundation, Inc
 // 
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -194,6 +194,8 @@ NetStream_as::bufferLength()
 #ifdef USE_MEDIA
     if (_parser.get() == nullptr) return 0;
     return _parser->getBufferLength();
+#else
+    return 0;
 #endif  // USE_MEDIA
 }
 
@@ -711,9 +713,10 @@ NetStream_as::decodeNextAudioFrame()
 #endif 
 
     raw->m_ptr = raw->m_data;
-#endif  // USE_MEDIA
-    
     return raw;
+#else   // USE_MEDIA
+    return nullptr;
+#endif
 }
 
 void
diff --git a/libcore/asobj/Sound_as.cpp b/libcore/asobj/Sound_as.cpp
index 4a6d11c..eddda73 100644
--- a/libcore/asobj/Sound_as.cpp
+++ b/libcore/asobj/Sound_as.cpp
@@ -1,6 +1,7 @@
 // Sound_as.cpp:  ActionScript "Sound" class, for Gnash.
 //
-//   Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+//   Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2016
+//   Free Software Foundation, Inc.
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -364,6 +365,7 @@ Sound_as::probeAudio()
 
     if (!_mediaParser) return; // nothing to do here w/out a media parser
 
+#ifdef USE_MEDIA
     if ( ! _soundLoaded ) {
 #ifdef GNASH_DEBUG_SOUND_AS
         log_debug("Probing audio for load");
@@ -441,6 +443,7 @@ Sound_as::probeAudio()
             assert(_audioDecoder.get());
         }
     }
+#endif  // USE_MEDIA
 #endif  // USE_SOUND
 }
 
@@ -810,12 +813,14 @@ Sound_as::getPosition() const
         return _soundHandler->tell(soundId);
     }
 
+#ifdef USE_MEDIA
     if (_mediaParser) {
         std::uint64_t ts;
         if ( _mediaParser->nextAudioFrameTimestamp(ts) ) {
             return ts;
         }
     }
+#endif  // USE_MEDIA
 #endif  // USE_SOUND
     
     return 0;
@@ -829,6 +834,7 @@ Sound_as::getAudio(std::int16_t* samples, unsigned int nSamples, bool& atEOF)
     int len = nSamples*2;
 
 #ifdef USE_SOUND
+#ifdef USE_MEDIA
     //GNASH_REPORT_FUNCTION;
 
     while (len) {
@@ -900,7 +906,12 @@ Sound_as::getAudio(std::int16_t* samples, unsigned int nSamples, bool& atEOF)
 
     atEOF=false;
     return nSamples-(len/2);
-#endif  // USE_SOUND
+#else   // USE_MEDIA
+    return 0;
+#endif
+#else   // USE_SOUND
+    return 0;
+#endif
 }
 
 // audio callback is running in sound handler thread
diff --git a/libcore/swf/SoundStreamHeadTag.cpp b/libcore/swf/SoundStreamHeadTag.cpp
index 3b20909..756ee06 100644
--- a/libcore/swf/SoundStreamHeadTag.cpp
+++ b/libcore/swf/SoundStreamHeadTag.cpp
@@ -1,5 +1,5 @@
 // 
-//   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
+//   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2016
 //   Free Software Foundation, Inc.
 // 
 // This program is free software; you can redistribute it and/or modify
@@ -146,8 +146,14 @@ SoundStreamHeadTag::loader(SWFStream& in, TagType tag, movie_definition& m,
 
     IF_VERBOSE_PARSE(
         log_parse(_("sound stream head: format=%s, rate=%d, 16=%d, "
-            "stereo=%d, ct=%d, latency=%d"), format, streamSoundRate,
-            +streamSound16bit, +streamSoundStereo, +sampleCount, +latency);
+            "stereo=%d, ct=%d, latency=%d"),
+#ifdef USE_MEDIA
+            format,
+#else
+            std::to_string(static_cast<int>(format)),
+#endif
+            streamSoundRate, +streamSound16bit, +streamSoundStereo,
+            +sampleCount, +latency);
     );
 
     // Store all the data in a SoundInfo object
diff --git a/libcore/swf/tag_loaders.cpp b/libcore/swf/tag_loaders.cpp
index c0da0ce..2f8f7a2 100644
--- a/libcore/swf/tag_loaders.cpp
+++ b/libcore/swf/tag_loaders.cpp
@@ -1,6 +1,6 @@
 // tag_loaders.cpp: SWF tags loaders, for Gnash.
 //
-//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2016
 //   Free Software Foundation, Inc
 //
 // This program is free software; you can redistribute it and/or modify
@@ -188,8 +188,13 @@ define_sound_loader(SWFStream& in, TagType tag, movie_definition& m,
 
     IF_VERBOSE_PARSE(
         log_parse(_("define sound: ch=%d, format=%s, rate=%d, 16=%d, "
-            "stereo=%d, ct=%d, delay=%d"), id, format, sample_rate,
-            sample_16bit, stereo, sample_count, delaySeek);
+            "stereo=%d, ct=%d, delay=%d"), id,
+#ifdef USE_MEDIA
+            format,
+#else
+            std::to_string(static_cast<int>(format)),
+#endif
+            sample_rate, sample_16bit, stereo, sample_count, delaySeek);
     );
 
     // If we have a sound_handler, ask it to init this sound.
diff --git a/libsound/Makefile.am b/libsound/Makefile.am
index a771188..1d0e092 100644
--- a/libsound/Makefile.am
+++ b/libsound/Makefile.am
@@ -1,5 +1,5 @@
 # 
-#   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
+#   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2016
 #    Free Software Foundation, Inc.
 # 
 # This program is free software; you can redistribute it and/or modify
@@ -73,8 +73,13 @@ libgnashsound_la_CPPFLAGS = \
 	$(SDL_CFLAGS) \
 	$(NULL)
 
-libgnashsound_la_LIBADD = \
-	$(top_builddir)/libmedia/libgnashmedia.la \
+if BUILD_LIBMEDIA
+libgnashsound_la_LIBADD = $(top_builddir)/libmedia/libgnashmedia.la
+else
+libgnashsound_la_LIBADD =
+endif
+
+libgnashsound_la_LIBADD += \
 	$(top_builddir)/libbase/libgnashbase.la \
 	$(BOOST_LIBS) \
 	$(SDL_LIBS) \
